package com.sd365.permission.centre.api;

import com.sd365.permission.centre.pojo.dto.DictionaryDTO;
import com.sd365.permission.centre.pojo.query.DictionaryQuery;
import com.sd365.permission.centre.pojo.vo.DictionaryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@CrossOrigin
@Api(tags = "字典管理",value = "permission/centre/v1/dictionary")
@RequestMapping(value = "/permission/centre/v1/dictionary")
public interface DictionaryApi {
    /**
     * @param: 字典DTO
     * @return: 成功则true CommonResponse 应答码和消息统一参考基础框架
     * @see
     * @since
     */

    @ApiOperation(tags="增加字典",value="")
    @PostMapping(value="")
    @ResponseBody
    Boolean add(@RequestBody @Valid DictionaryDTO dictionaryDTO);


    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    @ApiOperation(tags="删除字典",value="")
    @DeleteMapping(value="")
    @ResponseBody
    Boolean remove(@ApiParam(value = "当前行id", required = true) @RequestParam("id") Long id,
                   @ApiParam(value = "当前行版本", required = true) @RequestParam("version") Long version) throws Exception;


    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    @ApiOperation(tags="修改字典",value="")
    @PutMapping(value = "")
    @ResponseBody
    Boolean modify(@Valid DictionaryDTO dictionaryDTO) throws Exception;

    /**
     * 批量修改字典
     * @param customerDTOS
     * @return
     */
    @ApiOperation(tags="批量修改字典",value="")
    @PutMapping(value = "/batch")
    @ResponseBody
    Boolean batchUpdate(@Valid @RequestBody DictionaryDTO[] dictionaryDTOS) throws Exception;

    @ApiOperation(tags="批量删除字典",value="")
    @DeleteMapping(value = "/batch")
    @ResponseBody
    Boolean batchRemove(@Valid @RequestBody DictionaryDTO[] dictionaryDTOS) throws Exception;

    /**
     * @param: 被拷贝的记录id
     * @return: 拷贝后的完整对象
     * @see
     * @since
     */
    @ApiOperation(tags="拷贝字典",value="/copy")
    @PostMapping(value = "/copy")
    @ResponseBody
    DictionaryDTO copy(Long id);

    /**
     *  系统框架GlobalControllerResolver 类分析 参数是否 BaseQuery 类型 ，如果是则 拦截调用
     *  <br> PageHelper 分页方法， 并且将返回的page对象放入TheadLocal ，方法返回参数被 ResponseBodyAware拦截
     *  <br> 其判断 返回值的类型 如果是属于分页的请求则 自动将 List<DictionaryVO> 装入CommonPage
     *  <br> 并且构建统一应答回去 以上改进优化了 请求和应答的方法的编写
     * @param:
     * @return:
     * @see
     * @since
     */

    @ApiOperation(tags="查询字典",value="")
    @GetMapping(value = "")
    @ResponseBody
    List<DictionaryVO> commonQuery(DictionaryQuery dictionaryQuery);


    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    @ApiOperation(tags="查询字典通过ID",value="")
    @GetMapping(value = "{id}")
    @ResponseBody
    DictionaryVO queryDictionaryById(@PathVariable("id") Long id);

    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    @ApiOperation(tags="查询字典通过类型ID",value="/classify")
    @GetMapping(value = "/classify/{id}")
    @ResponseBody
    List<DictionaryVO> queryDictionaryByTypeId(@PathVariable("id") Long id);

}
